package com.hengxinguotong.hxgtwygsp.ui.supervise.patrol.info;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.PatrolInfo;

import java.util.List;

/**
 * Created by CS-Yong
 * 2019/8/9  15:58
 */
public class PatrolInfoAdapter extends BaseQuickAdapter<PatrolInfo, BaseViewHolder> {
    public PatrolInfoAdapter(int layoutResId, @Nullable List<PatrolInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PatrolInfo item) {
        helper.setText(R.id.patrol_time,item.getTime());
        helper.setText(R.id.patrol_name,item.getName());
        helper.setText(R.id.patrol_multiple_service_score,formatScore(item.getPoint1()));
        helper.setText(R.id.patrol_temp_patrol_score,formatScore(item.getPoint2()));
        helper.setText(R.id.patrol_public_order_score,formatScore(item.getPoint3()));
        helper.setText(R.id.patrol_public_device_score,formatScore(item.getPoint4()));
        helper.setText(R.id.patrol_health_green_score,formatScore(item.getPoint5()));
        helper.setText(R.id.patrol_rectify_status,item.getStatus());
        TextView mTvTotalScore = helper.getView(R.id.patrol_total_score);
        double totalScore = item.getTotalPoint();
        if (totalScore >=60){
            mTvTotalScore.setTextColor(mContext.getResources().getColor(R.color.cC8D8FF));
        }else {
            mTvTotalScore.setTextColor(mContext.getResources().getColor(R.color.cFE5956));
        }
        mTvTotalScore.setText(formatScore(totalScore));

    }

    private String formatScore(double score){
        return  String.format(mContext.getString(R.string.patrol_get_score),score);
    }
}
